#include <bits/stdc++.h>
// #define int long long
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int, int>
#define sws cin.tie(0)->sync_with_stdio(false);
#define endl '\n'
using namespace std;
const int N = 3e6+10;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-6;
const ld PI = acos(-1);
// #pragma GCC target("popcnt")
// End Template //
vector<int> div(int x) {
vector<int> ans;
for (ll i=1;i*i<=x;i++) {
if (x % i == 0) {
ans.pb(i);
if (i*i != x) ans.pb(x/i);
}
}
sort(ans.begin(), ans.end());
return ans;
}
int32_t main()
{sws;
int t; cin >> t;
while (t--) {
int n; cin >> n;
vector<ll> a(n), f(31, 0);
for (int i=0;i<n;i++) {
cin >> a[i];
for (int j=0;j<=30;j++) {
f[j] += !!(a[i] & (1LL << j));
}
}
int g = -1;
for (int j=0;j<=30;j++) {
if (f[j] == 0) continue;
if (g == -1) g = f[j];
g = gcd(g, f[j]);
}
if (g == -1) {
for (int i=1;i<=n;i++) {
cout << i << " ";
}
cout << endl;
} else {
vector<int> d = div(g);
for (auto di: d) {
cout << di << " ";
}
cout << endl;
}
}
return 0;
}
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |
Lexical Sorting Reloaded | 1514A - Perfectly Imperfect Array |